const mstts = require('mstts-js');
const fs = require('fs');

/**
 *
 * @param {*} text 文本
 * @param {*} voice 声音
    "CN":{
        "晓晓":"Xiaoxiao",
        "晓辰":"Xiaochen",
        "晓涵":"Xiaohan",
        "晓墨":"Xiaomo",
        "晓秋":"Xiaoqiu",
        "晓睿":"Xiaorui",
        "晓双":"Xiaoshuang",
        "晓萱":"Xiaoxuan",
        "晓颜":"Xiaoyan",
        "晓悠":"Xiaoyou",
        "云扬":"Yunyang",
        "云希":"Yunxi",
        "云野":"Yunye",
        "辽宁晓北":"LN-Xiaobei",
        "四川云希":"SC-Yunxi",
        "云皓":"Yunhao",
        "云健":"Yunjian"
    },
    "TW":{
        "曉臻":"HsiaoChen",
        "曉雨":"HsiaoYu",
        "雲哲":"YunJhe"
    },
    "HK":{
        "曉曼":"HiuMaan",
        "曉佳":"HiuGaai",
        "雲龍":"WanLung"
    }
 * @param {*} express 表现
 * @param {*} role 角色
 * @param {*} rate 速度
 * @param {*} pitch 音高
 * @returns
 */
let name = new Date().getTime() + '.mp3';
fs.readFile('./index.md', 'utf-8', async (err, data) => {
    const mp3buffer = await mstts.getTTSData(
        data,
        (voice = 'CN-Yunxi'),
        (express = 'general'),
        (role = ''),
        (rate = 0),
        (pitch = 0)
    );
    fs.writeFileSync(name, mp3buffer);
});
